package com.example.dnfgamercommunitybackend.controller;

import com.example.dnfgamercommunitybackend.entity.Account;
import com.example.dnfgamercommunitybackend.service.ManageAdminService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class ManageAdminController {
    @Resource
    private ManageAdminService manageAdminService;
    @PreAuthorize("hasAuthority('super_admin:add_admin')")
    @PostMapping("/admin/addAdmin")
    public String addAdmin(@RequestBody Account account){
        return manageAdminService.addAdmin(account);
    }

    @PreAuthorize("hasAuthority('super_admin:delete_admin')")
    @GetMapping("/admin/deleteAdmin")
    public String deleteAdmin(@RequestParam("adminId")int adminId){
        return manageAdminService.deleteAdmin(adminId);
    }

    @PreAuthorize("hasAuthority('super_admin:get_admin')")
    @GetMapping("/admin/getAllAdmin")
    public String getAllAdmin(){
        return manageAdminService.getAllAdmin();
    }
}
